Use protected HTTP wiring in examples and guides#2445
Merged
Conversation
Examples served over HTTP now bind loopback explicitly and get host and origin validation, matching the framework factories' defaults: most stories mount createMcpHandler via createMcpHonoApp, the hand-wired node:http stories compose the validation guards from @modelcontextprotocol/node in front of toNodeHandler, and the already-factory-based stories gain explicit 127.0.0.1 binds. The serving guide and example READMEs show the factory path as the default recipe.
🦋 Changeset detectedLatest commit: 588c873 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This was referenced Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Examples served over HTTP used bare
createServer(toNodeHandler(handler)).listen(port)wiring — binding all interfaces with no host or origin validation, while the framework factories (createMcpExpressApp,createMcpHonoApp,createMcpFastifyApp) apply localhost validation by default. Since examples are the wiring most deployments copy, they should demonstrate the protected path.Motivation and Context
createMcpHandlerviacreateMcpHonoApp(host/origin validation armed by default; the HTTP wiring in these stories is boilerplate, not the lesson).node:httprouting is load-bearing (elicitation's era-split routing,gateway's request-count instrumentation) keep it, composing the validation guards from@modelcontextprotocol/nodein front oftoNodeHandlerand binding127.0.0.1explicitly.examples/hono, which bound all interfaces while logging127.0.0.1, and the shared demo authorization server).docs/serving/http.md,examples/README.md, andexamples/CONTRIBUTING.mdnow show the factory path as the default recipe; bare wiring appears only together with the validation middleware.How Has This Been Tested?
check:all(typecheck, lint, docs build) andtest:allpass.Breaking Changes
None — examples and docs only. Example servers now bind loopback explicitly; stories remain runnable exactly as before via the examples runner.
Types of changes
Checklist